package com.qiujie.service;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.date.DateUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.qiujie.dto.Response;
import com.qiujie.dto.ResponseDTO;
import com.qiujie.entity.Config;
import com.qiujie.entity.Dept;
import com.qiujie.entity.Staff;
import com.qiujie.mapper.ConfigMapper;
import com.qiujie.vo.ConfigVO;
import com.qiujie.vo.StaffDeptVO;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class ConfigService extends ServiceImpl<ConfigMapper, Config> {


    @Resource
    private ConfigMapper configMapper;

    public ResponseDTO list(Config config) {
        QueryWrapper<Config> wrapper = new QueryWrapper<>();

        if (config.getType() != null) {
            wrapper.eq("type", config.getType());
        }

        List<Config> configList = configMapper.selectList(wrapper);
        List<ConfigVO> configVOList = new ArrayList<>();
        for (Config configItem : configList) {
            ConfigVO configVO = new ConfigVO();
            BeanUtils.copyProperties(configItem, configVO);
            // 将configItem的属性值复制到staffDeptVO中
            configVOList.add(configVO);
        }
        return Response.success(configVOList);
    }

}
